import Vue from 'vue'
import VueRouter from 'vue-router'
import BackstageManage from './ManageSystem/index'
import UserSystem from './UserSystem/index'

Vue.use(VueRouter)
const ManageChildren = [
  BackstageManage
]
const UserChildren = [
  UserSystem
]

const routes = [
  {
    path: '/manageLogin',
    name: 'ManageLogin',
    component: function (resolve) {
      require(['@/components/ManageLogin.vue'], resolve)
    }
  },
  {
    path: '/',
    name: 'userSystem',
    component: function (resolve) {
      require(['@/components/UserSystem.vue'], resolve)
    },
    redirect: '/index'
  },
  {
    path: '/userSystem',
    name: 'userSystem',
    component: function (resolve) {
      require(['@/components/UserSystem.vue'], resolve)
    },
    redirect: '/index',
    children: UserChildren
  },

  {
    path: '/manageSystem',
    name: 'manageSystem',
    component: function (resolve) {
      require(['@/components/ManageSystem.vue'], resolve)
    },
    redirect: '/userManage',
    children: ManageChildren
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
const VueRouterPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(to) {

  return VueRouterPush.call(this, to).catch(err => err)

}
export default router
